select_function(Ans) :-
	writeln('Welcome to the Car Purchase Expert System.'),
	writeln('Input 1 if you want to buy a new car.'),
	writeln('Input 2 to evaluate your car purchase plan.'),
	writeln('Input 3 to recommend cars.'),
	writeln('Input 4 to compare two cars.'),
	writeln('Input 5 to rank a certain brand cars.'),
	read(Ans).

fuzzy_or_precise(Ans) :-
	writeln('Input 1 to run fuzzy query.'),
	writeln('Input 2 to run precise query.'),
	read(Ans).

ask_aspect(A1, A2, A3, A4, A5, A6, A7, A8) :-
	writeln('1 means yes. 2 means no.'),
	writeln('Brand?'),
	read(A1),
	writeln('Budget?'),
	read(A2),
	writeln('Emission?'),
	read(A3),
	writeln('Vehicle_type?'),
	read(A4),
	writeln('Max_speed?'),
	read(A5),
	writeln('Length?'),
	read(A6),
	writeln('Width?'),
	read(A7),
	writeln('Height?'),
	read(A8).

ask_valued(A1, A2, A3, A4, A5, A6) :-
	writeln('What aspects do you value?'),
	writeln('1 means yes. 2 means no.'),
	writeln('Budget?'),
	read(A1),
	writeln('Emission?'),
	read(A2),
	writeln('Max_speed'),
	read(A3),
	writeln('Length?'),
	read(A4),
	writeln('Width?'),
	read(A5),
	writeln('Height?'),
	read(A6).

ask_brand(Brand) :-
	writeln('Which car brand do you want to choose?'),
	writeln('audi bmw mercedes_benz porsche'),
	writeln('ferrari lamborghini maserati aston_martin'),
	writeln('infiniti lexus bentley lincoln chevrolet'),
	writeln('honda mazda land_rover rolls_royce'),
	read(Brand).

ask_budget(Budget) :-
	writeln('What is your budget(in units of ten thousand RMB)?'),
	read(Budget).

ask_emission(Emission) :-
	writeln('What is your acceptable emissions(in units of milliliter)?'),
	read(Emission).

ask_vehicle_type(Vehicle_type) :-
	writeln('What is your expected vehicle type?'),
	read(Vehicle_type).

ask_max_speed(Max_speed) :-
	writeln('What is your expected max speed?'),
	read(Max_speed).

ask_length(Length) :-
	writeln('What is your expected length?'),
	read(Length).

ask_width(Width) :-
	writeln('What is your expected width?'),
	read(Width).

ask_height(Height) :-
	writeln('What is your expected height?'),
	read(Height).

get_expected_car_info(Brand, Budget, Emission, Vehicle_type, Max_speed, Length, Width, Height) :-
	ask_brand(Brand),
	ask_budget(Budget),
	ask_emission(Emission),
	ask_vehicle_type(Vehicle_type),
	ask_max_speed(Max_speed),
	ask_length(Length),
	ask_width(Width),
	ask_height(Height).

recommend(Size, Imported, Speeding, Purpose) :-
	writeln('Do you prefer a big car or a small car? Input 1 for big cars, 2 for small cars.'),
	read(Size),
	writeln('Do you prefer imported cars or home-made cars? Input 1 for imported cars, 2 for home-made cars.'),
	read(Imported),
	writeln('Do you enjoy speeding? Input 1 means yes, 2 means no.'),
	read(Speeding),
	writeln('What is your purpose for buying a car? Input 1 for convenience, 2 for traveling, 3 for speed racing.'),
	read(Purpose).

input_one_model(B1-M1-T1) :-
	writeln('Please input the brand of the car.'),
	read(B1),
	writeln('Please input the model of the car.'),
	read(M1),
	writeln('Please input the vehicle type of the car.'),
	read(T1).

input_two_models(B1-M1-T1, B2-M2-T2) :-
	writeln('Please input the brand of the first car.'),
	read(B1),
	writeln('Please input the model of the first car.'),
	read(M1),
	writeln('Please input the vehicle type of the first car.'),
	read(T1),
	writeln('Please input the brand of the second car.'),
	read(B2),
	writeln('Please input the model of the second car.'),
	read(M2),
	writeln('Please input the vehicle type of the second car.'),
	read(T2).

sort_by_aspect(Ans) :-
	writeln('Input 1 to sort cars by emission'),
	writeln('Input 2 to sort cars by max speed'),
	writeln('Input 3 to sort cars by price'),
	writeln('Input 4 to sort cars by length'),
	writeln('Input 5 to sort cars by width'),
	writeln('Input 6 to sort cars by height'),
	read(Ans).

write_line(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11) :-
	write('Brand: '), write(H1),
	write(', Model: '), write(H2),
	write(', Vehicle Type: '), write(H3),
	write(', Emission: '), write(H4),
	write(', Horsepower: '), write(H5),
	write(', Max Speed: '), write(H6),
	write(', Gear Box: '), write(H7),
	write(', Length: '), write(H8),
	write(', Width: '), write(H9),
	write(', Height: '), write(H10),
	write(', Price: '), writeln(H11).

write_line_by_emission(H4-H1-H2-H3-H5-H6-H7-H8-H9-H10-H11) :-
	write('Emission: '), write(H4),
	write(', Brand: '), write(H1),
	write(', Model: '), write(H2),
	write(', Vehicle Type: '), write(H3),
	write(', Horsepower: '), write(H5),
	write(', Max Speed: '), write(H6),
	write(', Gear Box: '), write(H7),
	write(', Length: '), write(H8),
	write(', Width: '), write(H9),
	write(', Height: '), write(H10),
	write(', Price: '), writeln(H11).

write_line_by_max_speed(H6-H1-H2-H3-H4-H5-H7-H8-H9-H10-H11) :-
	write('Max Speed: '), write(H6),
	write(', Brand: '), write(H1),
	write(', Model: '), write(H2),
	write(', Vehicle Type: '), write(H3),
	write(', Emission: '), write(H4),
	write(', Horsepower: '), write(H5),
	write(', Gear Box: '), write(H7),
	write(', Length: '), write(H8),
	write(', Width: '), write(H9),
	write(', Height: '), write(H10),
	write(', Price: '), writeln(H11).

write_line_by_budget(H11-H1-H2-H3-H4-H5-H6-H7-H8-H9-H10) :-
	write('Price: '), write(H11),
	write(', Brand: '), write(H1),
	write(', Model: '), write(H2),
	write(', Vehicle Type: '), write(H3),
	write(', Emission: '), write(H4),
	write(', Horsepower: '), write(H5),
	write(', Max Speed: '), write(H6),
	write(', Gear Box: '), write(H7),
	write(', Length: '), write(H8),
	write(', Width: '), write(H9),
	write(', Height: '), writeln(H10).

write_line_by_length(H8-H1-H2-H3-H4-H5-H6-H7-H9-H10-H11) :-
	write('Length: '), write(H8),
	write(', Brand: '), write(H1),
	write(', Model: '), write(H2),
	write(', Vehicle Type: '), write(H3),
	write(', Emission: '), write(H4),
	write(', Horsepower: '), write(H5),
	write(', Max Speed: '), write(H6),
	write(', Gear Box: '), write(H7),
	write(', Width: '), write(H9),
	write(', Height: '), write(H10),
	write(', Price: '), writeln(H11).

write_line_by_width(H9-H1-H2-H3-H4-H5-H6-H7-H8-H10-H11) :-
	write('Width: '), write(H9),
	write(', Brand: '), write(H1),
	write(', Model: '), write(H2),
	write(', Vehicle Type: '), write(H3),
	write(', Emission: '), write(H4),
	write(', Horsepower: '), write(H5),
	write(', Max Speed: '), write(H6),
	write(', Gear Box: '), write(H7),
	write(', Length: '), write(H8),
	write(', Height: '), write(H10),
	write(', Price: '), writeln(H11).

write_line_by_height(H10-H1-H2-H3-H4-H5-H6-H7-H8-H9-H11) :-
	write('Height: '), write(H10),
	write(', Brand: '), write(H1),
	write(', Model: '), write(H2),
	write(', Vehicle Type: '), write(H3),
	write(', Emission: '), write(H4),
	write(', Horsepower: '), write(H5),
	write(', Max Speed: '), write(H6),
	write(', Gear Box: '), write(H7),
	write(', Length: '), write(H8),
	write(', Width: '), write(H9),
	write(', Price: '), writeln(H11).

write_list([]).
write_list([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T]) :-
	write_line(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11),
	write_list(T).

write_list_by_emission([]).
write_list_by_emission([H4-H1-H2-H3-H5-H6-H7-H8-H9-H10-H11|T]) :-
	write_line_by_emission(H4-H1-H2-H3-H5-H6-H7-H8-H9-H10-H11),
	write_list_by_emission(T).

write_list_by_max_speed([]).
write_list_by_max_speed([H6-H1-H2-H3-H4-H5-H7-H8-H9-H10-H11|T]) :-
	write_line_by_max_speed(H6-H1-H2-H3-H4-H5-H7-H8-H9-H10-H11),
	write_list_by_max_speed(T).

write_list_by_budget([]).
write_list_by_budget([H11-H1-H2-H3-H4-H5-H6-H7-H8-H9-H10|T]) :-
	write_line_by_budget(H11-H1-H2-H3-H4-H5-H6-H7-H8-H9-H10),
	write_list_by_budget(T).

write_list_by_length([]).
write_list_by_length([H8-H1-H2-H3-H4-H5-H6-H7-H9-H10-H11|T]) :-
	write_line_by_length(H8-H1-H2-H3-H4-H5-H6-H7-H9-H10-H11),
	write_list_by_length(T).

write_list_by_width([]).
write_list_by_width([H9-H1-H2-H3-H4-H5-H6-H7-H8-H10-H11|T]) :-
	write_line_by_width(H9-H1-H2-H3-H4-H5-H6-H7-H8-H10-H11),
	write_list_by_width(T).

write_list_by_height([]).
write_list_by_height([H10-H1-H2-H3-H4-H5-H6-H7-H8-H9-H11|T]) :-
	write_line_by_height(H10-H1-H2-H3-H4-H5-H6-H7-H8-H9-H11),
	write_list_by_height(T).